package net.pws.oos.biz.model;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "b_task")
public class Task extends Locatable {

	private static final long serialVersionUID = -2165229348311980484L;

	public static final String DRAFT_STATUS = "draft";

	public static final String ASSIGNED_STATUS = "assigned";

	public static final String IN_PROGRESS_STATUS = "in_process";

	public static final String COMPLETED_STATUS = "completed";

	public static final String REJECTED_STATUS = "rejected";

	public static final String CREATE_TYPE_DISPATCH = "dispatch"; // 派发任务

	public static final String CREATE_TYPE_SELF = "self";// 自主任务
	
	public static final Integer PROSPEC_TTYPE_CHUKAN = 0; // 初勘
	
	public static final Integer PROSPEC_TTYPE_FUKAN = 1;// 复勘

	private String code;

	private String name;

	private String content;

	private String description;

	@Column(name = "manager_name")
	private String managerName;

	private String status;

	@Column(name = "plan_start_date")
	private Date planStartDate;

	@Column(name = "plan_end_date")
	private Date planEndDate;

	@Column(name = "real_start_date")
	private Date startDate;

	@Column(name = "real_end_date")
	private Date endDate;

	@Column(name = "assigned_date")
	private Date assignedDate;

	@Column(name = "station_code")
	private String stationCode;

	@Column(name = "station_name")
	private String stationName;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "template_id")
	private IndicatorTemplate template;
	
	@OneToOne(mappedBy="task")
	private ProspectRecod prospectRecod;

	// @ManyToOne(fetch = FetchType.LAZY)
	// @JoinColumn(name = "dist_id")
	// private District district;
	//
	// @Column(name = "district_code")
	// private String districtCode;
	//
	// @Column(name = "district_name")
	// private String districtName;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "proj_id")
	private Project project;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "exec_organ_id")
	private Organization executeOrganization;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "exec_person_id")
	private User executePerson;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "creator_id")
	private User creator;

	@Column(name = "create_datetime")
	private Date createDateTime;

	@Column(name = "phase")
	private String phase;

	@Column(name = "type")
	private String type;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id")
	private Task parent;

	// @ManyToOne(fetch = FetchType.LAZY)
	// @JoinColumn(name = "task_result_id")
	// private TaskResult result;

	@Column(name = "sync_status")
	private String syncStatus;

	@Column(name = "sync_datetime")
	private Date syncDateTime;

	@Column(name = "source_id")
	private String sourceId;

	@Column(name = "source_system")
	private String sourceSystem;

//	@Column(name = "rejected")
//	private Boolean rejected;

//	@Column(name = "reject_reason")
//	private String rejectReason;
//
//	@Column(name = "reject_count")
//	private Integer rejectCount;
//
//	@Column(name = "reject_by")
//	private String rejectBy;
//
//	@Column(name = "reject_date")
//	private Date rejectDate;

	@Column(name = "priority")
	private Integer priority = 1;

	@Column(name = "photo_require")
	private String photoRequire = "1";

	@Column(name = "subject")
	private String subject;

	@Column(name = "group_id")
	private String groupId;

	@Column(name = "create_type")
	private String createType = CREATE_TYPE_DISPATCH;
	
	/**
	 * 勘查类型 0：初勘；1：复勘
	 */
	@Column(name = "prospect_type")
	private Integer prospectType;

	/**
	 * 所属站点
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "station_id")
	private Station station;
	
	//////////////////////////////////新增属性
	/**
	 * 工程期数
	 */
	@Column(name = "proj_periods")
	private String projectPeriods;
	
	/**
	 * 地州
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "area_id")
	private Area area;
	
	/**
	 * 区县
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "county_id")
	private Area county;
	
	/**
	 * 乡镇
	 */
	@Column(name = "towns")
	private String towns;
	
	/**
	 * 站点类别
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "station_type")
	private IndicatorValue stationType;
	
	/**
	 * 基站名称
	 */
	@Column(name = "base_station_ame")
	private String baseStationName;
	
	/**
	 * 基站编码
	 */
	@Column(name = "base_station_code")
	private String baseStationCode;
	
	/**
	 * 主选点名称
	 */
	@Column(name = " main_separation")
	private String mainSeparation;
	
	/**
	 * 基站地址
	 */
	@Column(name = "base_station_site")
	private String baseStationSite;
	
	/**
	 * 海拔高度
	 */
	@Column(name = "altitude")
	private BigDecimal altitude;
	
	/**
	 * 相对高度
	 */
	@Column(name = "relative_height")
	private BigDecimal relativeHeight;

	/**
	 * 二搬距离
	 */
	@Column(name = "second_move_distance")
	private BigDecimal secondMoveDistance;

	/**
	 * 站址属性
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "site_properties")
	private IndicatorValue siteProperties;
	
	/**
	 * 配套产权归属
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "property_ownership")
	private IndicatorValue propertyOwnership;
	
	/**
	 * 区域类型
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "area_type")
	private IndicatorValue areaType;
	
	/**
	 * 覆盖目标
	 */
	@Column(name = "covering_target")
	private String coveringTarget;

	/**
	 * 工程建设模式
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "construction_model")
	private IndicatorValue constructionModel;
	
	/**
	 * 站点是否有效
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "site_valid")
	private IndicatorValue siteValid;
	
	/**
	 * 站点无效原因
	 */
	@Column(name = "site_valid_reason")
	private String siteValidReason;
	
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getAssignedDate() {
		return assignedDate;
	}

	public void setAssignedDate(Date assignedDate) {
		this.assignedDate = assignedDate;
	}

	public Date getPlanStartDate() {
		return planStartDate;
	}

	public void setPlanStartDate(Date planStartDate) {
		this.planStartDate = planStartDate;
	}

	public Date getPlanEndDate() {
		return planEndDate;
	}

	public void setPlanEndDate(Date planEndDate) {
		this.planEndDate = planEndDate;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getStationCode() {
		return stationCode;
	}

	public void setStationCode(String stationCode) {
		this.stationCode = stationCode;
	}

	public String getStationName() {
		return stationName;
	}

	public void setStationName(String stationName) {
		this.stationName = stationName;
	}

	// public District getDistrict() {
	// return district;
	// }
	//
	// public void setDistrict(District district) {
	// this.district = district;
	// }

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public Organization getExecuteOrganization() {
		return executeOrganization;
	}

	public void setExecuteOrganization(Organization executeOrganization) {
		this.executeOrganization = executeOrganization;
	}

	public User getExecutePerson() {
		return executePerson;
	}

	public void setExecutePerson(User executePerson) {
		this.executePerson = executePerson;
	}

	public User getCreator() {
		return creator;
	}

	public void setCreator(User creator) {
		this.creator = creator;
	}

	public Date getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Date createDateTime) {
		this.createDateTime = createDateTime;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getManagerName() {
		return managerName;
	}

	public void setManagerName(String managerName) {
		this.managerName = managerName;
	}

	// public String getDistrictCode() {
	// return districtCode;
	// }
	//
	// public void setDistrictCode(String districtCode) {
	// this.districtCode = districtCode;
	// }
	//
	// public String getDistrictName() {
	// return districtName;
	// }
	//
	// public void setDistrictName(String districtName) {
	// this.districtName = districtName;
	// }

	public String getPhase() {
		return phase;
	}

	public void setPhase(String phase) {
		this.phase = phase;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Task getParent() {
		return parent;
	}

	public void setParent(Task parent) {
		this.parent = parent;
	}

	public String getSyncStatus() {
		return syncStatus;
	}

	public void setSyncStatus(String syncStatus) {
		this.syncStatus = syncStatus;
	}

	public Date getSyncDateTime() {
		return syncDateTime;
	}

	public void setSyncDateTime(Date syncDateTime) {
		this.syncDateTime = syncDateTime;
	}

	// public TaskResult getResult() {
	// return result;
	// }
	//
	// public void setResult(TaskResult result) {
	// this.result = result;
	// }

	public String getSourceId() {
		return sourceId;
	}

	public void setSourceId(String sourceId) {
		this.sourceId = sourceId;
	}

	public String getSourceSystem() {
		return sourceSystem;
	}

	public void setSourceSystem(String sourceSystem) {
		this.sourceSystem = sourceSystem;
	}

//	public Boolean getRejected() {
//		return rejected;
//	}
//
//	public void setRejected(Boolean rejected) {
//		this.rejected = rejected;
//	}

//	public String getRejectReason() {
//		return rejectReason;
//	}
//
//	public void setRejectReason(String rejectReason) {
//		this.rejectReason = rejectReason;
//	}
//
//	public Integer getRejectCount() {
//		return rejectCount;
//	}
//
//	public void setRejectCount(Integer rejectCount) {
//		this.rejectCount = rejectCount;
//	}
//
//	public String getRejectBy() {
//		return rejectBy;
//	}
//
//	public void setRejectBy(String rejectBy) {
//		this.rejectBy = rejectBy;
//	}
//
//	@JsonSerialize(using = JsonDateTimeSerializer.class)
//	@JsonDeserialize(using = JsonDateDeserializer.class)
//	public Date getRejectDate() {
//		return rejectDate;
//	}
//
//	@JsonDeserialize(using = JsonDateDeserializer.class)
//	public void setRejectDate(Date rejectDate) {
//		this.rejectDate = rejectDate;
//	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public String getPhotoRequire() {
		return photoRequire;
	}

	public void setPhotoRequire(String photoRequire) {
		this.photoRequire = photoRequire;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	public String getCreateType() {
		return createType;
	}

	public void setCreateType(String createType) {
		this.createType = createType;
	}

	public IndicatorTemplate getTemplate() {
		return template;
	}

	public void setTemplate(IndicatorTemplate template) {
		this.template = template;
	}

	public ProspectRecod getProspectRecod() {
		return prospectRecod;
	}

	public void setProspectRecod(ProspectRecod prospectRecod) {
		this.prospectRecod = prospectRecod;
	}

	public Integer getProspectType() {
		return prospectType;
	}

	public void setProspectType(Integer prospectType) {
		this.prospectType = prospectType;
	}

	public Station getStation() {
		return station;
	}

	public void setStation(Station station) {
		this.station = station;
	}

	public String getProjectPeriods() {
		return projectPeriods;
	}

	public void setProjectPeriods(String projectPeriods) {
		this.projectPeriods = projectPeriods;
	}

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public Area getCounty() {
		return county;
	}

	public void setCounty(Area county) {
		this.county = county;
	}

	public String getTowns() {
		return towns;
	}

	public void setTowns(String towns) {
		this.towns = towns;
	}

	public IndicatorValue getStationType() {
		return stationType;
	}

	public void setStationType(IndicatorValue stationType) {
		this.stationType = stationType;
	}

	public String getBaseStationName() {
		return baseStationName;
	}

	public void setBaseStationName(String baseStationName) {
		this.baseStationName = baseStationName;
	}

	public String getBaseStationCode() {
		return baseStationCode;
	}

	public void setBaseStationCode(String baseStationCode) {
		this.baseStationCode = baseStationCode;
	}

	public String getMainSeparation() {
		return mainSeparation;
	}

	public void setMainSeparation(String mainSeparation) {
		this.mainSeparation = mainSeparation;
	}

	public String getBaseStationSite() {
		return baseStationSite;
	}

	public void setBaseStationSite(String baseStationSite) {
		this.baseStationSite = baseStationSite;
	}

	public BigDecimal getAltitude() {
		return altitude;
	}

	public void setAltitude(BigDecimal altitude) {
		this.altitude = altitude;
	}

	public BigDecimal getRelativeHeight() {
		return relativeHeight;
	}

	public void setRelativeHeight(BigDecimal relativeHeight) {
		this.relativeHeight = relativeHeight;
	}

	public BigDecimal getSecondMoveDistance() {
		return secondMoveDistance;
	}

	public void setSecondMoveDistance(BigDecimal secondMoveDistance) {
		this.secondMoveDistance = secondMoveDistance;
	}

	public IndicatorValue getSiteProperties() {
		return siteProperties;
	}

	public void setSiteProperties(IndicatorValue siteProperties) {
		this.siteProperties = siteProperties;
	}

	public IndicatorValue getPropertyOwnership() {
		return propertyOwnership;
	}

	public void setPropertyOwnership(IndicatorValue propertyOwnership) {
		this.propertyOwnership = propertyOwnership;
	}

	public IndicatorValue getAreaType() {
		return areaType;
	}

	public void setAreaType(IndicatorValue areaType) {
		this.areaType = areaType;
	}

	public String getCoveringTarget() {
		return coveringTarget;
	}

	public void setCoveringTarget(String coveringTarget) {
		this.coveringTarget = coveringTarget;
	}

	public IndicatorValue getConstructionModel() {
		return constructionModel;
	}

	public void setConstructionModel(IndicatorValue constructionModel) {
		this.constructionModel = constructionModel;
	}

	public IndicatorValue getSiteValid() {
		return siteValid;
	}

	public void setSiteValid(IndicatorValue siteValid) {
		this.siteValid = siteValid;
	}

	public String getSiteValidReason() {
		return siteValidReason;
	}

	public void setSiteValidReason(String siteValidReason) {
		this.siteValidReason = siteValidReason;
	}

}
